package com.pos.clothes.controller;

import com.pos.clothes.service.CancelService;
import com.pos.clothes.util.JsonData;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequiresPermissions(value = {"1","2"},logical = Logical.OR)
//@RequiresPermissions("3")
public class CancelController {
    @Autowired
    CancelService service;
    @RequestMapping("/returnSingle")
    @ResponseBody
     public Object returnSingle(@RequestParam Integer normid,
                                @RequestParam Integer orderid,
                                @RequestParam Integer userid,
                                @RequestParam Integer number,
                                @RequestParam Float toatal,
                                @RequestParam String note){
        Integer res = service.insertCancel(userid,orderid,normid,number,toatal,note);
        if(res==1){
            return JsonData.buildSuccess("退货成功");
        }
        return JsonData.buildError("退货失败");
     }
     @RequestMapping("/getReturnNorm")
     @ResponseBody
     public Object getReturnNorm(@RequestParam Integer orderid){

        return JsonData.buildSuccess(service.getReturnNorm(orderid),"ok");
     }
}
